<?php
/**
 * TomatoCMS
 *
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 *
 * @copyright    Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license        http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version        $Id: category.phtml 5186 2010-08-30 12:02:46Z huuphuoc $
 * @since        2.0.0
 */
?>
<?php
$this->headTitle($this->category->name);
?>
<style>
    .t_news_category{
        padding-top:20px;
    }
</style>
<?php if(count($this->categories) > 0):?>
    <?php foreach ($this->categories as $category):?>
        <?php if (count($articles = $this->latestArticles($category->category_id, $this->limit)) > 0) : ?>
            <div class="t_news_category">
                <div class="box subcolumns">
                    <div class="cufon_title">
                        <div class="inner">
                            <h3><a href="<?php echo $this->url($category->getProperties(), 'news_article_category'); ?>"><?php echo $category->name; ?></a></h3>
                        </div>
                    </div>
                </div>
                <ul>
                    <?php foreach ($articles as $article) : ?>
                    <li>
                        <a href="<?php echo $this->url($article->getProperties(), 'news_article_details'); ?>"><?php echo $article->title; ?></a>
                    </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        <?php endif; ?>
    <?php endforeach;?>
<?php else:?>
    <div class="t_news_category">
        <div class="box subcolumns">
            <div class="cufon_title">
                <div class="inner">
                    <h3><?php echo $this->category->name?></h3>
                </div>
            </div>
        </div>
        <ul>
        <?php foreach ($this->articles as $index => $article) : ?>
            <li>
                <a href="<?php echo $this->url($article->getProperties(), 'news_article_details'); ?>"><?php echo $article->title; ?></a>
                <?php echo $this->articleIcons($article->icons); ?>
                <cite><?php echo date($this->globalConfig('web')->datetime->format->datetime, strtotime($article->activate_date)); ?></cite>

                <?php if ($article->image_small) : ?>
                <div class="image">
                    <a href="<?php echo $this->url($article->getProperties(), 'news_article_details'); ?>">
                        <img src="<?php echo $article->image_small; ?>" />
                    </a>
                </div>
                <?php endif; ?>

                <div class="description"><?php echo $article->description; ?></div>

            </li>
        <?php endforeach; ?>
        </ul>

        <div class="paginator">
            <?php echo $this->paginator()->slide($this->paginator, $this->paginatorOptions); ?>
        </div>
    </div>
<?php endif;?>